package com.ruiysoft.controller.order.vo;

import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.validation.annotation.Validated;

import java.util.NoSuchElementException;
import java.util.Objects;

/**
 * OrderModifyVo
 */
@Validated
@javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2019-04-13T15:37:30.389+08:00")

public class OrderModifyVo {
    @JsonProperty("orderNo")
    private String orderNo = null;

    @JsonProperty("finalAmount")
    private Long finalAmount = null;

    @JsonProperty("amountType")
    private Integer amountType = null;

    public OrderModifyVo orderNo(String orderNo) {
        this.orderNo = orderNo;
        return this;
    }

    /**
     * 订单号
     *
     * @return orderNo
     **/
    @ApiModelProperty(value = "订单号")


    public String getOrderNo() {
        return orderNo;
    }

    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }

    public OrderModifyVo finalAmount(Long finalAmount) {
        this.finalAmount = finalAmount;
        return this;
    }

    /**
     * 最终金额
     *
     * @return finalAmount
     **/
    @ApiModelProperty(value = "最终金额")


    public Long getFinalAmount() {
        return finalAmount;
    }

    public void setFinalAmount(Long finalAmount) {
        this.finalAmount = finalAmount;
    }

    public OrderModifyVo amountType(Integer amountType) {
        this.amountType = OrderModifyMoneyTypeEnum.valueOf(amountType).getValue();
        return this;
    }

    /**
     * 1 订单总额 2 运费
     *
     * @return amountType
     **/
    @ApiModelProperty(example = "1", value = "1 订单总额 2 运费")


    public Integer getAmountType() {
        return amountType;
    }

    public void setAmountType(Integer amountType) {
        this.amountType = OrderModifyMoneyTypeEnum.valueOf(amountType).getValue();
    }


    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        OrderModifyVo orderModifyVo = (OrderModifyVo) o;
        return Objects.equals(this.orderNo, orderModifyVo.orderNo) &&
                Objects.equals(this.finalAmount, orderModifyVo.finalAmount) &&
                Objects.equals(this.amountType, orderModifyVo.amountType);
    }

    @Override
    public int hashCode() {
        return Objects.hash(orderNo, finalAmount, amountType);
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append("class OrderModifyVo {\n");

        sb.append("    orderNo: ").append(toIndentedString(orderNo)).append("\n");
        sb.append("    finalAmount: ").append(toIndentedString(finalAmount)).append("\n");
        sb.append("    amountType: ").append(toIndentedString(amountType)).append("\n");
        sb.append("}");
        return sb.toString();
    }

    /**
     * Convert the given object to string with each line indented by 4 spaces
     * (except the first line).
     */
    private String toIndentedString(Object o) {
        if (o == null) {
            return "null";
        }
        return o.toString().replace("\n", "\n    ");
    }


    public enum OrderModifyMoneyTypeEnum {

        orderMainMoney(1 << 0), orderLogisticMoney(1 << 1);

        private final int value;

        private OrderModifyMoneyTypeEnum(int value) {
            this.value = value;
        }

        public int getValue() {
            return value;
        }

        public static OrderModifyMoneyTypeEnum valueOf(int type){
            for(OrderModifyMoneyTypeEnum typeEnum : OrderModifyMoneyTypeEnum.values()){
                if (typeEnum.getValue() == type){
                    return typeEnum;
                }
            }
            throw new NoSuchElementException(String.format("No sush type [%d]",type));
        }
    }
}

